package com.axun.ckz.yytmanager.base;

import android.app.AlertDialog;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Toast;

import com.axun.ckz.yytmanager.R;


/**
 * Created by ckz on 2018/5/3.
 */

public class BaseFragment extends Fragment implements IBaseView{
    private AlertDialog dialog;
    private View contentView;
    @Nullable
    @Override
    public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {

        return super.onCreateView(inflater, container, savedInstanceState);
    }

    public void showToast(String toast){
        Toast.makeText(getContext(),toast,Toast.LENGTH_SHORT).show();
    }

    @Override
    public void showProgress(String progres) {
        dialog = new AlertDialog.Builder(getContext(), R.style.LoadDialog).create();
        contentView = LayoutInflater.from(getContext()).inflate(R.layout.dialog_progress,null);
        dialog.show();
        dialog.setContentView(contentView);
    }

    @Override
    public void hideProgress() {
        if (dialog!=null&&dialog.isShowing()){
            dialog.dismiss();
        }
    }

    @Override
    public void showUI(String json) {

    }

    @Override
    public void showError(String error) {
        showToast(error);
    }

    @Override
    public void showFaild(String msg) {
        showToast(msg);
    }
}
